package util.designpattern.strategyPattern;

import java.util.HashMap;
import java.util.Map;

/**
 * 支付策略类
 */
public class PayStrategy {
    public static final String ALI_PAY = "ALiPay";
    public static final String JD_PAY = "JdiPay";
    public static final String WECHAT_PAY = "WechatPay";
    public static final String UNION_PAY = "UnionPay";
    public static final String DEFAULT_PAY = ALI_PAY;

    private static Map<String, Payment> paymentMap = new HashMap<String, Payment>();
    static {
        paymentMap.put(ALI_PAY,new AliPay());
        paymentMap.put(JD_PAY,new AliPay());
        paymentMap.put(WECHAT_PAY,new AliPay());
        paymentMap.put(UNION_PAY,new AliPay());
    }

    public static Payment get(String payKey){
        if(!paymentMap.containsKey(payKey)){
            return  paymentMap.get(DEFAULT_PAY);
        }
        return paymentMap.get(payKey);
    }
}
